<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  <title>WinForm script</title>
  <xml></xml>
  <link rel="stylesheet" type="text/css" href="MSDN.css">
</head>
<body id="bodyID" class="dtBODY">
<div id="nsbanner">
<div id="bannerrow1">
<table class="bannerparthead" cellspacing="0">
          <tbody>
    <tr id="hdr">
            <td class="runninghead">
      <p align="left">CS-Script 3.27.0</p>
            </td>
            <td class="product">
            </td>
          </tr>
  </tbody>
</table>
      </div>
<div id="TitleRow">
<h1 class="dtH1" align="left">Using WinForms</h1>
      </div>
    </div>
<div id="nstext">
<h4 class="dtH4">Step-by-step tutorial</h4>
<p>The following tutorial shows how to create and execute the simple script that uses
WinForm.</p>
<ol>
  <li>
    <p>By using any text editor (eg. Notepad.exe) create file <i> WinForm.cs</i> that contains the WinForm sample
    code. <br>
Click here to obtain <a href="Tutorial/WinForm.cs"> listing of <i> WinForm.cs</i></a></p>
  </li>
  <li>
    <p>Open command prompt. Make sure current directory is the directory where <i> WinForm.cs</i> is located.</p>
  </li>
  <li>
    <p>Execute the following command in command prompt:</p>
    <div class="syntax">
 csws WinForm
    </div>
  </li>
</ol>
<h4 class="dtH4">
Output</h4>
<p>The script will create and show the following dialog.</p>
<p align="center"><img src="Images/WinForm.PNG" border="0" height="140" width="258"></p>
<h4 class="dtH4"> <br>
<br>
Code discussion</h4>
<p>
In this example the script creates an instance of FCL class <font style="color: rgb(51, 0, 153);" color="#0000ff">System.Windows.Forms.Form</font>. The form initialisation code is placed into
<font color="#0000ff"><span style="color: rgb(51, 0, 153);">
InitializeComponent()</span> </font> method to make it compatible with the Visual
Studio form designer however it can be placed in any other appropriate
place (eg. <font style="color: rgb(51, 0, 153);" color="#0000ff"> Form1</font> constructor).&nbsp;&nbsp;</p>
<p>&nbsp;</p>
<h4 class="dtH4">Hints and Tips</h4>
<p>This example is a part of sample library (<i>cs-script/Samples</i> folder). It
can be easily recreated to be used as a skeleton code for your WinForm
script. To do this execute the following command in your code:</p>
<div class="syntax">
 cscs sample WinForm
</div>
<p>
This will instruct the script engine to output sample code in a file in the current directory.</p>
<p>&nbsp;</p>
<h4 class="dtH4">
See Also</h4>
<p><a href="Tutorial.html">CS-Script tutorials</a> |&nbsp;<a href="Command-line_Interface.html">Command-line
interface</a> </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" viewastext="true" style="display: none;">
	<param name="Keyword" value="WinForm">
</object> 
    </div>
</body>
</html>

